const mongoose = require('mongoose');
const mongoSetting = require('../setting').mongo;
const logger = require('../utils/loggers/logger')
mongoose.Promise = Promise;
const Schema = mongoose.Schema;
const ObjectId = mongoose.Types.ObjectId;
const uri = mongoSetting.url || process.env.DATABASE_URL || "mongodb://localhost:27017/acfun";
mongoose.connect(uri, { useNewUrlParser: true });
var db = mongoose.connection;
db.on('error', e => console.error.bind(console, 'connection error:' + e));
db.once('open', function () {
    console.log("db connection!")
    // we're connected!
});

module.exports = db;